package com.handinfo.android.ui.window;

import android.graphics.Bitmap;

import com.handinfo.android.DWGameManager;
import com.handinfo.android.core.graphics.DWFont;
import com.handinfo.android.ui.ChatItem;
import com.handinfo.android.ui.IUIWindows;
import com.handinfo.android.ui.UIWindows;
import com.handinfo.android.uicontrols.DWAbsHyperlink;
import com.handinfo.android.uicontrols.DWControlsManager;
import com.handinfo.android.uicontrols.DWHyperlink;
import com.handinfo.android.uicontrols.DWListener;
import com.handinfo.android.uicontrols.controls.DWBackground;
import com.handinfo.android.uicontrols.controls.DWButton;
import com.handinfo.android.uicontrols.controls.DWFrame;
import com.handinfo.android.uicontrols.controls.DWImageBox;
import com.handinfo.android.uicontrols.controls.DWInputBox;
import com.handinfo.android.uicontrols.controls.DWListSubItem;
import com.handinfo.android.uicontrols.controls.DWListbox;
import com.handinfo.android.uicontrols.controls.DWPopMenu;
import com.handinfo.android.uicontrols.controls.DWTabControl;
import com.handinfo.android.uicontrols.controls.DWTabPage;
import com.handinfo.android.uicontrols.controls.DWTextbox;
import com.handinfo.android.uicontrols.controls.DWTitle;
import com.handinfo.android.utils.Tools;

public class UILiaoTianWindow implements IUIWindows
{

	public boolean m_flag_select = true;
	public DWFrame m_liaotian_Frame = null;
	DWFrame m_biaoqing_Frame = null;

	Bitmap m_cr_xxbj = null;
	Bitmap m_cr_tuichu;// 叉键退出
	Bitmap m_cr_tit = null;
	Bitmap m_cr_tit_biaoqing = null;
	Bitmap m_cr_tab_1;// 点击前图片
	Bitmap m_cr_tab_2;// 点击后图片
	Bitmap m_cr_but = null;// 按钮
	Bitmap m_cr_but_down = null;
	Bitmap m_cr_caidan = null;

	DWBackground m_xbjd_bg; // ////小背景中的大的
	DWBackground m_xbjx_bg; // ////小背景中的小的
	DWBackground m_biaoqing_xbj_bg; ////表情
	DWTitle m_liaotian_tit; ////标题
	DWTabControl m_tabcontrol = null; /////标签容器
	DWTabPage m_tp[];////标签页

	DWImageBox m_tuichu_ima; ////退出
	DWImageBox m_tit_ima;
	DWImageBox m_tit_ima_biaoqing;
	DWImageBox m_biaoqing_1;
	DWImageBox m_biaoqing_2;
	DWImageBox m_biaoqing_3;
	DWImageBox m_biaoqing_4;
	DWImageBox m_biaoqing_5;
	DWImageBox m_biaoqing_6;
	DWImageBox m_biaoqing_7;
	DWImageBox m_biaoqing_8;
	DWImageBox m_biaoqing_9;
	DWImageBox m_biaoqing_10;
	DWImageBox m_biaoqing_11;
	DWImageBox m_biaoqing_12;
	DWImageBox m_biaoqing_13;
	DWImageBox m_biaoqing_14;
	DWImageBox m_biaoqing_15;
	DWImageBox m_biaoqing_16;
	DWImageBox m_biaoqing_17;
	DWImageBox m_biaoqing_18;

	DWButton m_pindao_but; //// 频道按钮
	DWButton m_beibao_but; ////背包按钮
	DWButton m_biaoqing_but;////表情按钮
	DWButton m_fasong_but;////发送按钮
	DWButton m_huishan_but;
	DWButton m_kuaijie_but;
	DWInputBox m_inputbox = null; ////输入框
	DWPopMenu m_chaolianjie_pm; ////超级链接菜单
	DWPopMenu m_pindao_pm;

	String m_pindao_name[] = new String[] { "世界", "世界", "阵营", "家族", "队伍", "世界", "私聊" };
	private final String[] m_stringname = { "全部", "世界", "阵营", "家族", "队伍", "系统", "私聊" };
	private float m_send_size = 0;

	byte[] m_type = { ChatItem.TYPE_QUAN,
			ChatItem.TYPE_WORLD,
			ChatItem.TYPE_REALM,
			ChatItem.TYPE_FAMILY,
			ChatItem.TYPE_TEAM,
			ChatItem.TYPE_XI,
			ChatItem.TYPE_SI };
	private DWListbox[] m_chats_list = null;
	private DWTextbox m_click_textbox = null;//被点击的textbox

	public void LiaoTian()
	{
//		if (DWControlsManager.getInstance().contains(m_liaotian_Frame)) {
//			if (m_liaotian_Frame != null) {
//				DWControlsManager.getInstance().removeControl(m_liaotian_Frame);
//			}
//		}
		m_flag = true;
		// ////画布	
		m_liaotian_Frame = new DWFrame(DWFrame.FRAME_TYPE_FULL, true);
		m_liaotian_Frame.setClickClose(false);
		// ////标题
		m_liaotian_tit = new DWTitle("", m_liaotian_Frame);
		m_tit_ima = new DWImageBox(m_cr_tit);
		m_tit_ima.setNearAnchor(m_liaotian_tit, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);
		// //小背景中的大的图片
		m_xbjd_bg = new DWBackground(m_cr_xxbj,
				((m_liaotian_Frame.getShowWidth() - 30) / 5) * 4, m_liaotian_Frame.getShowHeight()
						- (m_liaotian_tit.getShowHeight() - 20) - m_cr_tab_2.getHeight() - 20 - m_cr_but.getHeight());

		// /////小背景中的小的图片 放三个按钮的
		m_xbjx_bg = new DWBackground(m_cr_xxbj,
				((m_liaotian_Frame.getShowWidth() - 30) / 5) * 1, m_xbjd_bg.getShowHeight());

		// ///////////小背景中的大图片的靠近
		m_xbjd_bg.setNearAnchor(
				m_liaotian_Frame,
				Tools.LEFT_TOP,
				Tools.LEFT_TOP,
				(m_liaotian_Frame.getShowWidth() - m_xbjd_bg.getShowWidth()
						- m_xbjx_bg.getShowWidth() - 10) / 2,
				m_cr_tab_2.getHeight() + (m_liaotian_tit.getShowHeight() - 20));

		// ///////////小背景中的小图片的靠近
		m_xbjx_bg.setNearAnchor(m_xbjd_bg, Tools.LEFT_TOP, Tools.RIGHT_TOP, 10, 0);

		// ///标签页
		////标签容器
		m_tabcontrol = new DWTabControl(m_cr_tab_1, m_cr_tab_2,
				m_xbjd_bg.getShowWidth() - 8, m_xbjd_bg.getShowHeight()
						+ m_cr_tab_2.getHeight());

		m_tabcontrol.setNearAnchor(m_xbjd_bg, Tools.LEFT_TOP, Tools.LEFT_TOP,
				12, -m_cr_tab_2.getHeight());
		m_tabcontrol.addListener(m_tp_lis);

		////刷新数据方法
		m_chats_list = new DWListbox[m_stringname.length];
		m_tp = new DWTabPage[m_stringname.length];
		for (int i = 0; i < m_stringname.length; i++) {
			m_tp[i] = new DWTabPage();
			m_tp[i].setName(m_stringname[i]);
			m_chats_list[i] = new DWListbox(m_xbjd_bg.getShowWidth() - 30, m_xbjd_bg.getShowHeight() - 18);
			m_chats_list[i].setNearAnchor(m_tp[i], Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 9);
//			m_chats_list[i].setBottom(true);
			m_chats_list[i].setShowBackgroundRect(false);
			m_chats_list[i].setLineSpacing(8);
			ChatItem[] cis = DWGameManager.getInstance().m_role.getChatItemFitType(m_type[i]);
			if (cis != null && cis.length > 0) {
				for (int j = 0; j < cis.length; j++) {
					ChatItem ci = cis[j];
					DWListSubItem m_lsi = new DWListSubItem();
					DWTextbox tb = new DWTextbox(ci.m_content, m_chats_list[i].getShowWidth());
					tb.setNearAnchor(m_lsi, Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
					tb.addListener(m_chats_lis);
					m_lsi.addControls(tb);
					m_chats_list[i].addSubItem(m_lsi);
				}
			}
			m_tp[i].addControls(m_chats_list[i]);
			m_tabcontrol.addTabPage(m_tp[i]);
		}
		DWGameManager.getInstance().m_role.resetChatsUpdateNum();

		// //退出图片按钮
		m_tuichu_ima = new DWImageBox(m_cr_tuichu);
		m_tuichu_ima.setNearAnchorUn(m_liaotian_tit, Tools.RIGHT_TOP,
				Tools.RIGHT_TOP, 0, 0);
		m_tuichu_ima.setTouchZoomIn(40, 40);
		m_tuichu_ima.addListener(m_tuichu_lis);

		// //频道
		m_pindao_but = new DWButton(m_pindao_name[0], m_cr_caidan);
		m_pindao_but.setDownImage(m_cr_but_down);
		m_pindao_but.setNearAnchor(
				m_xbjd_bg,
				Tools.LEFT_TOP,
				Tools.LEFT_BOTTOM,
				0, 10);
		m_pindao_but.addListener(m_pindao_lis);

		// /输入框
		m_inputbox = new DWInputBox(m_xbjd_bg.getShowWidth() + m_xbjx_bg.getShowWidth()+10-2*m_cr_but.getWidth() - 20,
				m_cr_but.getHeight()-20, m_liaotian_Frame);
		m_inputbox.setChat(true);
//		m_inputbox.setFont(DWFont.getFont(13));
		m_inputbox.setNearAnchor(m_pindao_but, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER, 10, 0);
		
		m_huishan_but = new DWButton("← 回删", m_cr_but);
		m_huishan_but.setDownImage(m_cr_but_down);
		m_huishan_but.setNearAnchor(m_inputbox, Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER,10, 0);
		m_huishan_but.addListener(new DWListener() {
			
			public void OnDoubleClick()
			{
			}
			
			public void OnClick()
			{
				if(m_inputbox.getText() != null && !m_inputbox.getText().equals(""))
				{
					if(m_inputbox.getText().toString().length()==0)
					{
						DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "内容为空，无需删除。");
					}
					else if(m_inputbox.getText().toString().length()==1)
					{
						m_inputbox.setText("");
					}
					else
					{
						m_inputbox.deleteLastOne();
					}
				}
				else
				{
					DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "内容为空，无需删除。");
				}
			}
		});
		// //背包
		m_beibao_but = new DWButton("背包", m_cr_but);
		m_beibao_but.setDownImage(m_cr_but_down);
		m_beibao_but.setNearAnchor(m_xbjx_bg, Tools.LEFT_TOP, Tools.LEFT_TOP,
				(m_xbjx_bg.getShowWidth() - m_beibao_but.getShowWidth()) / 2,
				(m_xbjx_bg.getShowHeight() - m_beibao_but.getShowHeight() * 4) / 5);
		m_beibao_but.addListener(m_beibao_lis);

		// //表情
		m_biaoqing_but = new DWButton("表情", m_cr_but);
		m_biaoqing_but.setDownImage(m_cr_but_down);
		m_biaoqing_but.setNearAnchor(m_beibao_but, Tools.LEFT_TOP, Tools.LEFT_BOTTOM,
				0, (m_xbjx_bg.getShowHeight() - m_beibao_but.getShowHeight() * 4) / 5);
		m_biaoqing_but.addListener(m_biaoqing_lis);

		///快捷语句
		m_kuaijie_but = new DWButton("短语", m_cr_but);
		m_kuaijie_but.setDownImage(m_cr_but_down);
		m_kuaijie_but.setNearAnchorUn(m_biaoqing_but, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0,
				(m_xbjx_bg.getShowHeight() - m_beibao_but.getShowHeight() * 4) / 5);
		m_kuaijie_but.addListener(m_kuaijie_lis);

		// //发送
		m_fasong_but = new DWButton("发送", m_cr_but);
		m_fasong_but.setDownImage(m_cr_but_down);
		m_fasong_but.setNearAnchorUn(m_kuaijie_but, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0,
				(m_xbjx_bg.getShowHeight() - m_beibao_but.getShowHeight() * 4) / 5);
		m_fasong_but.addListener(m_send_lis);

		
		m_liaotian_Frame.addControl(m_liaotian_tit);
		m_liaotian_Frame.addControl(m_tit_ima);
		m_liaotian_Frame.addControl(m_xbjd_bg);
		m_liaotian_Frame.addControl(m_xbjx_bg);
		m_liaotian_Frame.addControl(m_tabcontrol);
		m_liaotian_Frame.addControl(m_tuichu_ima);
		m_liaotian_Frame.addControl(m_inputbox);
		m_liaotian_Frame.addControl(m_huishan_but);
		m_liaotian_Frame.addControl(m_pindao_but);
		m_liaotian_Frame.addControl(m_beibao_but);
		m_liaotian_Frame.addControl(m_biaoqing_but);
		m_liaotian_Frame.addControl(m_fasong_but);
		m_liaotian_Frame.addControl(m_kuaijie_but);

		DWControlsManager.getInstance().addControl(m_liaotian_Frame);

		m_send_size = DWFont.getDefaultFont().stringWidth("国") * 35;
	}

	/**
	 * 每一条聊天记录的监听
	 */
	Boolean m_flag;//判断私聊是否是在聊天的界面点击玩家名称超链接的私聊的布尔变量
	private DWListener m_chats_lis = new DWListener() {
		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			DWListbox lb = m_chats_list[m_tabcontrol.getPageIndex()];
			if (lb != null) {
				int index = lb.getTouchIndex();
				if (lb != null && lb.getSubItemSize() > index && index >= 0) {
					m_click_textbox = (DWTextbox) (lb.getListSubItem(index).getControl(0));
					if (m_click_textbox != null && m_click_textbox.getHyperlinkKey() != null) {
						if (m_click_textbox.getHyperlinkType() == DWAbsHyperlink.URL_PLAYER)
						{
							if (!m_click_textbox.getHyperlnkContent().equals(DWGameManager.getInstance().m_role.m_name))
							{
								if(!m_click_textbox.getHyperlnkContent().equals("系统"))
								{
									ChaoLianJie_order();
								}
							}
							else if (m_click_textbox.getHyperlnkContent().equals(
									DWGameManager.getInstance().m_role.m_name))
							{
								DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
										"点击自己名字超链接无操作相应，请点击他人名字。");
							}
						}
						else if (m_click_textbox.getHyperlinkType() == DWAbsHyperlink.URL_ACTORITEM)
						{
							DWGameManager.getInstance().getSendMessage().sendSeeItemInfos(0,
									m_click_textbox.getHyperlinkKey());
						}
					}
				}
			}
		}
	};

	/**
	 * 更新聊天记录
	 */
	public void updateChats()
	{
		if (m_chats_list == null) {
			return;
		}
		if (m_liaotian_Frame == null) {
			return;
		}
		Tools.debugPrintln("更新聊天记录!");
		//更新所有页
		for (int i = 0; i < m_stringname.length; i++) {
			byte type=m_type[i];
			int delete;
			int add;
			if (type==ChatItem.TYPE_QUAN) {
				delete=DWGameManager.getInstance().m_role.m_chats_delete_quan;
				for (int j = 0; j < delete; j++) {
					m_chats_list[i].removeSubItem(j);
				}
				add=DWGameManager.getInstance().m_role.m_chats_add_quan;
			}else {
				delete = DWGameManager.getInstance().m_role.m_chats_delete[type];
				for (int j = 0; j < delete; j++) {
					m_chats_list[i].removeSubItem(j);
				}
				add = DWGameManager.getInstance().m_role.m_chats_add[type];
			}
			ChatItem[] cis = DWGameManager.getInstance().m_role.getChatItemFitType(type);
			if (cis != null) {
				int len = cis.length;
				if (len > 0 && add <= len) {
					DWListbox listbox = m_chats_list[i];
					for (int j = 0; j < add; j++) {
						ChatItem ci = cis[len - add + j];
						DWListSubItem lsi = new DWListSubItem();
						DWTextbox tb = new DWTextbox(ci.m_content, listbox.getShowWidth());
						tb.setNearAnchor(lsi, Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
						tb.addListener(m_chats_lis);
						lsi.addControls(tb);
						listbox.addSubItem(lsi);
					}
				}
			}			
//			//删除条数
//			int delete = DWGameManager.getInstance().m_role.m_chats_delete[m_type[i] + 1];
//			for (int j = 0; j < delete; j++) {
//				m_chats_list[i].removeSubItem(j);
//			}
//			//添加条数
//			int add = DWGameManager.getInstance().m_role.m_chats_add[m_type[i] + 1];
//			ChatItem[] cis = DWGameManager.getInstance().m_role.getChatItemFitType(m_type[i]);
//			if (cis != null) {
//				int len = cis.length;
//				if (len > 0 && add <= len) {
//					DWListbox listbox = m_chats_list[i];
//					for (int j = 0; j < add; j++) {
//						ChatItem ci = cis[len - add + j];
//						DWListSubItem lsi = new DWListSubItem();
//						DWTextbox tb = new DWTextbox(ci.m_content, listbox.getShowWidth());
//						tb.setNearAnchor(lsi, Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
//						tb.addListener(m_chats_lis);
//						lsi.addControls(tb);
//						listbox.addSubItem(lsi);
//					}
//				}
//			}
		}
		DWGameManager.getInstance().m_role.resetChatsUpdateNum();
	}

	/**
	 * 快捷语句监听
	 */
	private DWListener m_kuaijie_lis = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			Kuaijie();
		}
	};
	DWFrame m_kuaijie_frame = null;
	DWBackground m_kuaijie_xbj = null;
	String m_duanyu[] = new String[] { "互加好友，摇钱浇水!",
										"求给力的家族收留!",
										"求带，求包养！",
										"求组队，求副本!",
										"找老公，求关爱!",
										"找老婆，求幸福!",
										"等我，马上到!",
										"先去吃饭了,一会回来!",
										"竞技场排队中，跪求一战!",
										"我下了，诸位再见!" };

	DWListbox m_kuaijie_listbox = null;
	DWTextbox m_tb[] = new DWTextbox[m_duanyu.length];
	Bitmap m_cr_duanyu_tit = null;

	public void Kuaijie()
	{
		if (DWControlsManager.getInstance().contains(m_kuaijie_frame)) {
			if (m_kuaijie_frame != null) {
				DWControlsManager.getInstance().removeControl(m_kuaijie_frame);
			}
		}
		///画布
		m_kuaijie_frame = new DWFrame(DWFrame.FRAME_TYPE_HALF_RIGHT, true);
		DWControlsManager.getInstance().addControl(m_kuaijie_frame);
		m_kuaijie_frame.setClickClose(false);

		//标题
		DWTitle m_tit = new DWTitle("", m_kuaijie_frame);
		m_kuaijie_frame.addControl(m_tit);
		DWImageBox m_tit_ima = new DWImageBox(m_cr_duanyu_tit);
		m_tit_ima.setNearAnchor(m_tit, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);
		m_kuaijie_frame.addControl(m_tit_ima);

		//退出叉键
		DWImageBox m_tuichu_ima = new DWImageBox(m_cr_tuichu);
		m_tuichu_ima.setNearAnchor(m_tit, Tools.RIGHT_VCENTER, Tools.RIGHT_VCENTER, 0, 0);
		m_tuichu_ima.setTouchZoomIn(40, 40);
		m_tuichu_ima.addListener(new DWListener() {

			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				DWControlsManager.getInstance().removeControl(m_kuaijie_frame);
			}
		});
		m_kuaijie_frame.addControl(m_tuichu_ima);

		///小背景
		m_kuaijie_xbj = new DWBackground(m_kuaijie_frame.getShowWidth() - 20, m_kuaijie_frame.getShowHeight()
				- (m_tit.getShowHeight() - 20) - 20);
		m_kuaijie_xbj.setNearAnchor(m_kuaijie_frame, Tools.LEFT_TOP, Tools.LEFT_TOP, 10,
				m_tit.getShowHeight() - 20 + 10);
		m_kuaijie_frame.addControl(m_kuaijie_xbj);

		///内容列表
		m_kuaijie_listbox = new DWListbox(m_kuaijie_xbj.getShowWidth() - 20, m_kuaijie_xbj.getShowHeight() - 10);
		m_kuaijie_listbox.setNearAnchor(m_kuaijie_xbj, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);
		m_kuaijie_listbox.setLineSpacing(8);
		m_kuaijie_frame.addControl(m_kuaijie_listbox);

		for (int i = 0; i < m_duanyu.length; i++) {
			DWListSubItem m_lsi = new DWListSubItem();

			m_tb[i] = new DWTextbox(m_duanyu[i], m_kuaijie_listbox.getShowWidth());
			m_tb[i].setNearAnchor(m_lsi, Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
			m_tb[i].addListener(m_duanyu_lis);

			m_lsi.addControls(m_tb[i]);
			m_kuaijie_listbox.addSubItem(m_lsi);
		}
	}

	/**
	 * 短语的监听
	 */
	private DWListener m_duanyu_lis = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			if (m_inputbox.getText() != null) {
				m_inputbox.setText(m_inputbox.getText() + m_tb[m_kuaijie_listbox.getTouchIndex()].getText());
			}
			else {
				m_inputbox.setText(m_tb[m_kuaijie_listbox.getTouchIndex()].getText());
			}
			DWControlsManager.getInstance().removeControl(m_kuaijie_frame);
		}
	};
	/**
	 * 发送监听
	 */
	private DWListener m_send_lis = new DWListener() {
		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			if (m_inputbox.getText() == null || m_inputbox.getText().equals(""))
			{
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "发言内容不能为空。");
			}
			else
			{
				String sendText = m_inputbox.getText();
				float text = 0;
				if (sendText != null) {
					if (DWHyperlink.isHyperLink(sendText)) {
						text = DWFont.getDefaultFont().stringWidth(DWHyperlink.removeHyper(sendText));
					} else {
						text = DWFont.getDefaultFont().stringWidth(sendText);
					}
				}
				if (!m_pindao_but.getName().equals("私聊"))
				{
					if (text > m_send_size) {
						DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
								"发送文字过多,内容最多不可超过35个字!");
					}
					else
					{
						if (m_pindao_but.getName().equals("世界"))
						{
							DWGameManager.getInstance().getSendMessage().sendChatWorld(m_inputbox.getText());
							m_inputbox.setText("");
							m_flag = true;
							UIWindows.getInstance().m_checked.m_miyu_flag = true;
							UIWindows.getInstance().m_social.m_shejiao_siliao_flag = true;
							UIWindows.getInstance().m_social.m_other_flag = true;
							UIWindows.getInstance().m_social.m_own_flag = true;
							UIWindows.getInstance().m_nearby.m_near_flag = true;

						}
						else if (m_pindao_but.getName().equals("阵营"))
						{
							DWGameManager.getInstance().getSendMessage().sendChatRealm(m_inputbox.getText());
							m_inputbox.setText("");
							m_flag = true;
							UIWindows.getInstance().m_checked.m_miyu_flag = true;
							UIWindows.getInstance().m_social.m_shejiao_siliao_flag = true;
							UIWindows.getInstance().m_social.m_other_flag = true;
							UIWindows.getInstance().m_social.m_own_flag = true;
							UIWindows.getInstance().m_nearby.m_near_flag = true;
						}
						else if (m_pindao_but.getName().equals("家族"))
						{
							if (DWGameManager.getInstance().m_role.m_family_name == null
									|| DWGameManager.getInstance().m_role.m_family_name.equals(""))
							{
								DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
										"您还没有家族，不能家族喊话。");
							}
							else
							{
								DWGameManager.getInstance().getSendMessage().sendChatFamily(m_inputbox.getText());
								m_inputbox.setText("");
								m_flag = true;
								UIWindows.getInstance().m_checked.m_miyu_flag = true;
								UIWindows.getInstance().m_social.m_shejiao_siliao_flag = true;
								UIWindows.getInstance().m_social.m_other_flag = true;
								UIWindows.getInstance().m_social.m_own_flag = true;
								UIWindows.getInstance().m_nearby.m_near_flag = true;
							}
						}
						else if (m_pindao_but.getName().equals("队伍"))
						{
							if (DWGameManager.getInstance().m_role.m_teamID != 0)
							{
								DWGameManager.getInstance().getSendMessage().sendChatTeam(m_inputbox.getText());
								m_inputbox.setText("");
								m_flag = true;
								UIWindows.getInstance().m_checked.m_miyu_flag = true;
								UIWindows.getInstance().m_social.m_shejiao_siliao_flag = true;
								UIWindows.getInstance().m_social.m_other_flag = true;
								UIWindows.getInstance().m_social.m_own_flag = true;
								UIWindows.getInstance().m_nearby.m_near_flag = true;
							}
							else
							{
								DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
										"您还没有队伍，不能队伍喊话。");
							}
						}
					}
				}
				else {
					if (m_pindao_but.getName().equals("私聊"))
					{
						////排行界面发出的私聊
						if (m_inputbox.getText().toString().length() == 0)
						{
							DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
									"缺少对方昵称及发送内容。");
							return;
						}
						if (m_inputbox.getText().toString().length() == 1)
						{
							if (m_inputbox.getText().indexOf(":") != -1)
							{
								DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
										"缺少对方昵称及发送内容。");
								return;
							}
							else
							{
								DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
										"缺少对方昵称,无法私聊。");
								return;
							}
						}
						if (m_inputbox.getText().indexOf(":") == -1)
						{
							DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
									"缺少私聊对方昵称，无法私聊。");
						}
						else
						{
							if (m_inputbox.getText().substring(0).equals(":"))
							{
								DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
										"缺少私聊对方昵称，无法私聊。");
								
							}
							if ((m_inputbox.getText().substring(0, m_inputbox.getText().indexOf(":")))
											.toString().length() > 6)
							{
								DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
										"对方昵称错误，请检查昵称长度是否大于6。");
							}
							else if ((m_inputbox.getText().substring(0, m_inputbox.getText().indexOf(":")))
									.toString().length() == 0)
							{
								DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
										"缺少私聊对方名称，无法发送。");
							}
//							else if(m_name_index.equals("系统"))
//							{
//								DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
//								"缺少私聊对方名称，无法发送。");
//							}
							else
							{
								if (m_inputbox.getText().substring(m_inputbox.getText().indexOf(":") + 1,
										m_inputbox.getText().toString().length()).toString().length() == 0)
								{
									DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
											"私聊内容不能为空。");
									return;
								}
								else if (text > m_send_size - 6)
								{
									DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
											"私聊内容长度不可超过35个字。");
									return;
								}
								else if (!(m_inputbox.getText().substring(0, m_inputbox.getText().indexOf(":")))
										.equals(m_name_index))
								{
									Tools.debugPrintln("内容剩余的部分："+m_inputbox.getText().substring(0, m_inputbox.getText().indexOf(":"))
											+";m_name_index:"+m_name_index);
									DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
											"无法直接输入私聊对方的昵称进行私聊。");
									return;
								}
								DWGameManager.getInstance().getSendMessage().sendChatItemCommitPrivate(
										m_id_index,
										m_inputbox.getText().substring(m_inputbox.getText().indexOf(":") + 1,m_inputbox.getText().toString().length()));
								m_inputbox.setText(m_name_index + ":");
							}
						}
//						if (m_flag)
//						{
//							if (m_inputbox.getText().indexOf(":") != -1)
//							{
//								if(m_inputbox.getText().substring(m_inputbox.getText().indexOf(":") + 1,m_inputbox.getText().toString().length()-1).toString().length() == 0)
//								{
//									DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "私聊内容不能为空。");
//									return;
//								}
//								else if(m_inputbox.getText().substring(m_inputbox.getText().indexOf(":") + 1,m_inputbox.getText().toString().length()-1).toString().length() >35)
//								{
//									DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "私聊内容长度不可超过35个字。");
//									return;
//								}
//								////目标密语
//								if(!UIWindows.getInstance().m_checked.m_miyu_flag)
//								{
//									DWGameManager.getInstance().getSendMessage().sendChatItemCommitPrivate(
//											DWGameManager.getInstance().m_role.m_targetActor.m_gameId,///id应该是密语的对方的id
//											m_inputbox.getText().substring(m_inputbox.getText().indexOf(":") + 1));
//								}
//								else if(UIWindows.getInstance().m_checked.m_miyu_flag)
//								{
//									if(!UIWindows.getInstance().m_social.m_shejiao_siliao_flag)
//									{
//										DWGameManager.getInstance().getSendMessage().sendChatItemCommitPrivate(
//												UIWindows.getInstance().m_social.m_cyrm_id,
//												m_inputbox.getText().substring(m_inputbox.getText().indexOf(":") + 1));
//									}
//									else
//									{
//										if(!UIWindows.getInstance().m_social.m_other_flag)
//										{
//											DWGameManager.getInstance().getSendMessage().sendChatItemCommitPrivate(
//											UIWindows.getInstance().m_social.m_other_id,m_inputbox.getText().substring(m_inputbox.getText().indexOf(":") + 1));
//										}
//										else
//										{
//											if(!UIWindows.getInstance().m_social.m_own_flag)
//											{
//												DWGameManager.getInstance().getSendMessage().sendChatItemCommitPrivate(
//														UIWindows.getInstance().m_social.m_own_id,m_inputbox.getText().substring(m_inputbox.getText().indexOf(":") + 1));
//											}
//											else
//											{
//												if(!UIWindows.getInstance().m_nearby.m_near_flag)
//												{
//													DWGameManager.getInstance().getSendMessage().sendChatItemCommitPrivate(
//															UIWindows.getInstance().m_nearby.m_near_id,m_inputbox.getText().substring(m_inputbox.getText().indexOf(":") + 1));
//												}
//												else
//												{
//													DWGameManager.getInstance().getSendMessage().sendChatItemCommitPrivate(
//															UIWindows.getInstance().m_rank.m_id_chuandi,
//															m_inputbox.getText().substring(m_inputbox.getText().indexOf(":") + 1));
//												}
//											}
//										}
//									}
//								}
//								
//								m_inputbox.setText("");
//								m_flag = true;
//								UIWindows.getInstance().m_checked.m_miyu_flag = true;
//								UIWindows.getInstance().m_social.m_shejiao_siliao_flag = true;
//								UIWindows.getInstance().m_social.m_other_flag = true;
//								UIWindows.getInstance().m_social.m_own_flag = true;
//								UIWindows.getInstance().m_nearby.m_near_flag = true;
//							}
//							else
//							{
//								DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
//										"缺少私聊对方名称，无法发送。");
//							}
//						}
//						else if (!m_flag)
//						{
//							///聊天界面超链接发出的私聊
//							if (m_click_textbox != null && m_click_textbox.getHyperlinkKey() != null
//									&& m_click_textbox.getHyperlinkType() == DWAbsHyperlink.URL_PLAYER)
//							{
//								if (m_inputbox.getText().indexOf(":") != -1)
//								{
//									if(m_inputbox.getText().substring(m_inputbox.getText().indexOf(":") + 1,m_inputbox.getText().toString().length()-1).toString().length() == 0)
//									{
//										DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "私聊内容不能为空。");
//										return;
//									}
//									else if(m_inputbox.getText().substring(m_inputbox.getText().indexOf(":") + 1,m_inputbox.getText().toString().length()-1).toString().length() >35)
//									{
//										DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "私聊内容长度不可超过35个字。");
//										return;
//									}
//									DWGameManager.getInstance().getSendMessage().sendChatItemCommitPrivate(
//											Long.parseLong(m_click_textbox.getHyperlinkKey()),
//											m_inputbox.getText().substring(m_inputbox.getText().indexOf(":") + 1));
//									m_inputbox.setText("");
//									m_flag = true;
//									UIWindows.getInstance().m_checked.m_miyu_flag = true;
//									UIWindows.getInstance().m_social.m_shejiao_siliao_flag = true;
//									UIWindows.getInstance().m_social.m_other_flag = true;
//									UIWindows.getInstance().m_social.m_own_flag = true;
//									UIWindows.getInstance().m_nearby.m_near_flag = true;
//								}
//								else
//								{
//									DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
//											"缺少私聊对方名称，无法发送。");
//								}
//							}
//						}
					}
				}
			}
		}
	};

	private DWListener m_tp_lis = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			int m_index = m_tabcontrol.getPageIndex();
			int m_num[] = new int[] { 0, 1, 2, 3, 4, 5, 6 };
			for (int i = 0; i < m_num.length; i++)
			{
				if (m_num[i] == m_index)
				{
					if (m_pindao_but != null)
					{
						m_pindao_but.setName(m_pindao_name[i]);
					}
				}
			}
			m_inputbox.setText("");
		}
	};
	private DWListener m_tuichu_lis = new DWListener() {

		public void OnDoubleClick()
		{

		}

		public void OnClick()
		{
			DWControlsManager.getInstance().removeControl(m_liaotian_Frame);
			UIWindows.getInstance().m_checked.m_miyu_flag = true;
			UIWindows.getInstance().m_social.m_shejiao_siliao_flag = true;
			UIWindows.getInstance().m_social.m_other_flag = true;
			UIWindows.getInstance().m_social.m_own_flag = true;
			UIWindows.getInstance().m_nearby.m_near_flag = true;
		}
	};
	String m_pindao_name_1[] = new String[] { "世界", "阵营", "家族", "队伍" };
	// ////频道监听
	private DWListener m_pindao_lis = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			m_pindao_pm = new DWPopMenu(m_pindao_name_1, m_cr_but);
			m_pindao_pm.setDownImage(m_cr_but_down);
			m_pindao_pm.addListener(m_pindao_caidan_lis);

			m_liaotian_Frame.addControl(m_pindao_pm);
		}
	};

	// /////////频道菜单的监听
	private DWListener m_pindao_caidan_lis = new DWListener() {

		public void OnDoubleClick()
		{

		}

		public void OnClick()
		{
			int m_index = m_pindao_pm.getIndex();
			m_pindao_but.setName(m_pindao_name_1[m_index]);
			m_liaotian_Frame.removeControl(m_pindao_pm);
		}
	};

	// ///////////////////超级链接的菜单函数/////////////////
	public void ChaoLianJie_order()
	{
		final String[] m_name = new String[] { "私聊", "查看", "发送邮件", "组队",
				"加为好友", "加黑名单", "发布通缉令"  };
		m_chaolianjie_pm = new DWPopMenu(m_name, m_cr_but);
		m_chaolianjie_pm.setDownImage(m_cr_but_down);
		m_chaolianjie_pm.addListener(m_chaolianjie_caidan_lis);
		m_liaotian_Frame.addControl(m_chaolianjie_pm);
	}

	// ////超级链接的菜单监听
	private DWListener m_chaolianjie_caidan_lis = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			int m_index = m_chaolianjie_pm.getIndex();
			if (m_index == 0) {
				///私聊
				if (m_click_textbox != null && m_click_textbox.getHyperlnkContent() != null
						&& m_click_textbox.getHyperlinkType() == DWAbsHyperlink.URL_PLAYER) {
					m_flag = false;
					m_inputbox.setText(m_click_textbox.getHyperlnkContent() + ":");
					m_pindao_but.setName("私聊");
					ID(Long.parseLong(m_click_textbox.getHyperlinkKey()));
					Name(m_click_textbox.getHyperlnkContent());
				}
			}
			else if (m_index == 1) {
				///人物属性列表
				if (m_click_textbox != null && m_click_textbox.getHyperlnkContent() != null
						&& m_click_textbox.getHyperlinkType() == DWAbsHyperlink.URL_PLAYER)
				{
					DWGameManager.getInstance().getSendMessage().sendSeeOtherRoleInfo(
							Long.parseLong(m_click_textbox.getHyperlinkKey()));
				}

			}
			else if (m_index == 2) {
				////邮件
				if(DWGameManager.getInstance().m_role.isSellStatus()){
					DWGameManager.getInstance().addSystemInfo(
							DWGameManager.SYSTEM_INFO_TYPE_B, "摆摊中，无法操作！");
				}
				else
				{
					UIWindows.getInstance().m_mail.open((byte) 0);
					UIWindows.getInstance().m_mail.m_tabcontrol.setSelectPage(1);
					if (m_click_textbox != null && m_click_textbox.getHyperlnkContent() != null
							&& m_click_textbox.getHyperlinkType() == DWAbsHyperlink.URL_PLAYER) {
						UIWindows.getInstance().m_mail.m_send_recv_ib.setText(m_click_textbox.getHyperlnkContent());
					}
				}
			}
			else if (m_index == 3) {
				///组队
				if(DWGameManager.getInstance().m_role.isSellStatus()){
					DWGameManager.getInstance().addSystemInfo(
							DWGameManager.SYSTEM_INFO_TYPE_B, "摆摊中，无法操作！");
				}
				else
				{
					if (m_click_textbox != null && m_click_textbox.getHyperlnkContent() != null
							&& m_click_textbox.getHyperlinkType() == DWAbsHyperlink.URL_PLAYER)
					{
						DWGameManager.getInstance().getSendMessage().sendTeamRequest(
								Long.parseLong(m_click_textbox.getHyperlinkKey()));
					}
				}
			}
			else if (m_index == 4) {//添加好友
				if(DWGameManager.getInstance().m_role.isSellStatus()){
					DWGameManager.getInstance().addSystemInfo(
							DWGameManager.SYSTEM_INFO_TYPE_B, "摆摊中，无法操作！");
				}
				else
				{
					if (m_click_textbox != null && m_click_textbox.getHyperlnkContent() != null
							&& m_click_textbox.getHyperlinkType() == DWAbsHyperlink.URL_PLAYER) {
						DWGameManager.getInstance().getSendMessage().sendSocialAddForName(UISocial.SOCIAL_TYPE_FRIEND,
								m_click_textbox.getHyperlnkContent());
					}
				}
			}
			else if (m_index == 5){//添加黑名单
				if(DWGameManager.getInstance().m_role.isSellStatus()){
					DWGameManager.getInstance().addSystemInfo(
							DWGameManager.SYSTEM_INFO_TYPE_B, "摆摊中，无法操作！");
				}
				else
				{
					if (m_click_textbox != null && m_click_textbox.getHyperlnkContent() != null
							&& m_click_textbox.getHyperlinkType() == DWAbsHyperlink.URL_PLAYER) {
						DWGameManager.getInstance().getSendMessage().sendSocialAddForName(UISocial.SOCIAL_TYPE_BLACKLIST,
								m_click_textbox.getHyperlnkContent());
					}
				}
			}
			else if (m_index == 6){//发布通缉令
				if(DWGameManager.getInstance().m_role.isSellStatus()){
					DWGameManager.getInstance().addSystemInfo(
							DWGameManager.SYSTEM_INFO_TYPE_B, "摆摊中，无法操作！");
				}
				else
				{
					if (m_click_textbox != null && m_click_textbox.getHyperlnkContent() != null
							&& m_click_textbox.getHyperlinkType() == DWAbsHyperlink.URL_PLAYER) {
						//需要向服务器请求角色属性后开启界面
						UIWindows.getInstance().m_warrant.open((byte) 0);
						UIWindows.getInstance().m_warrant.setMessage(ID(Long.parseLong(m_click_textbox.getHyperlinkKey())),
								Name(m_click_textbox.getHyperlnkContent()));
					}
				}
			}
			m_liaotian_Frame.removeControl(m_chaolianjie_pm);
		}
	};

	// ///背包监听
	private DWListener m_beibao_lis = new DWListener() {
		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			UIWindows.getInstance().m_bag.open((byte) UIBag.BAG_STATE_LIAOTIAN);
		}
	};

	// ///表情监听及表情界面
	private DWListener m_biaoqing_lis = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			Biaoqing();
		}
	};

	private String getBiaoqing(int index)
	{
		return "<pic i=" + index + "></pic>";
	}

	DWListbox m_biaoqing_listbox = null;

	private void Biaoqing()
	{
		if (DWControlsManager.getInstance().contains(m_biaoqing_Frame)) {
			if (m_biaoqing_Frame != null) {
				DWControlsManager.getInstance().removeControl(m_biaoqing_Frame);
			}
		}
		//////表情的画布，右半屏
		m_biaoqing_Frame = new DWFrame(DWFrame.FRAME_TYPE_HALF_RIGHT, true);
		m_biaoqing_Frame.setClickClose(false);

		////标题
		DWTitle m_biaoqing_tit = new DWTitle("", m_biaoqing_Frame);
		m_tit_ima_biaoqing = new DWImageBox(m_cr_tit_biaoqing);
		m_tit_ima_biaoqing.setNearAnchor(m_biaoqing_tit, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);
		// /// 小背景图片
		m_biaoqing_xbj_bg = new DWBackground(m_biaoqing_Frame.getShowWidth() - 30,
				m_biaoqing_Frame.getShowHeight() - (m_biaoqing_tit.getShowHeight() - 20) - 30);
		m_biaoqing_xbj_bg.setNearAnchor(m_biaoqing_Frame, Tools.LEFT_TOP, Tools.LEFT_TOP, 15, 15 + m_biaoqing_tit
				.getShowHeight() - 20);

		/////定义一个表情数组，将每个表情的图片都放进数组里存放起来
		Bitmap m_cr_biaoqing_tu[][] = new Bitmap[][] {
				{
						DWControlsManager.getInstance().img_biaoqing[0],
						DWControlsManager.getInstance().img_biaoqing[1],
						DWControlsManager.getInstance().img_biaoqing[2]
				},
				{
						DWControlsManager.getInstance().img_biaoqing[3],
						DWControlsManager.getInstance().img_biaoqing[4],
						DWControlsManager.getInstance().img_biaoqing[5] },
				{
						DWControlsManager.getInstance().img_biaoqing[6],
						DWControlsManager.getInstance().img_biaoqing[7],
						DWControlsManager.getInstance().img_biaoqing[8] },
				{
						DWControlsManager.getInstance().img_biaoqing[9],
						DWControlsManager.getInstance().img_biaoqing[10],
						DWControlsManager.getInstance().img_biaoqing[11] },
				{
						DWControlsManager.getInstance().img_biaoqing[12],
						DWControlsManager.getInstance().img_biaoqing[13],
						DWControlsManager.getInstance().img_biaoqing[14] },
				{
						DWControlsManager.getInstance().img_biaoqing[15],
						DWControlsManager.getInstance().img_biaoqing[16],
						DWControlsManager.getInstance().img_biaoqing[17] } };

		/////定义一个图片按钮数组，将每一个表情的图片按钮都放进数组存放起来
		DWImageBox m_biaoqing_all_tu[][] = new DWImageBox[][] {
				{ m_biaoqing_1, m_biaoqing_2, m_biaoqing_3 },
				{ m_biaoqing_4, m_biaoqing_5, m_biaoqing_6 },
				{ m_biaoqing_7, m_biaoqing_8, m_biaoqing_9 },
				{ m_biaoqing_10, m_biaoqing_11, m_biaoqing_12 },
				{ m_biaoqing_13, m_biaoqing_14, m_biaoqing_15 },
				{ m_biaoqing_16, m_biaoqing_17, m_biaoqing_18 }
		};

		//////listbox
		m_biaoqing_listbox = new DWListbox(m_biaoqing_xbj_bg.getShowWidth() - 30,
				m_biaoqing_xbj_bg.getShowHeight() - 40);
		m_biaoqing_listbox.setLineSpacing(15);
		m_biaoqing_listbox.setShowBackgroundRect(false);
		m_biaoqing_listbox.setNearAnchor(m_biaoqing_xbj_bg, Tools.LEFT_TOP, Tools.LEFT_TOP, 10, 20);

		DWListSubItem m_biaoqing_subitem;
		for (int i = 0; i < 6; i++) {
			m_biaoqing_subitem = new DWListSubItem();
			for (int j = 0; j < 3; j++) {
				m_biaoqing_all_tu[i][j] = new DWImageBox(m_cr_biaoqing_tu[i][j]);
				if (j == 0) {
					m_biaoqing_all_tu[i][j]
							.setNearAnchor(
									m_biaoqing_subitem,
									Tools.LEFT_TOP,
									Tools.LEFT_TOP,
									(m_biaoqing_xbj_bg.getShowWidth() - 3 * m_biaoqing_all_tu[i][j].getShowWidth()) / 4 - 10,
									0);
				}
				else {
					m_biaoqing_all_tu[i][j].setNearAnchor(m_biaoqing_all_tu[i][j - 1], Tools.LEFT_TOP, Tools.RIGHT_TOP,
							(m_biaoqing_xbj_bg.getShowWidth() - 3 * m_biaoqing_all_tu[i][j].getShowWidth()) / 4, 0);
				}
				final int index = i * 3 + j;
				m_biaoqing_all_tu[i][j].addListener(new DWListener() {

					public void OnDoubleClick()
					{
					}

					public void OnClick()
					{
						DWControlsManager.getInstance().removeControl(m_biaoqing_Frame);
						if (m_inputbox.getText() != null) {
							m_inputbox.setText(m_inputbox.getText() + getBiaoqing(index));
						}
						else {
							m_inputbox.setText(getBiaoqing(index));
						}
					}
				});
				m_biaoqing_subitem.addControls(m_biaoqing_all_tu[i][j]);
			}
			m_biaoqing_listbox.addSubItem(m_biaoqing_subitem);
		}

		//////叉键退出
		m_tuichu_ima = new DWImageBox(m_cr_tuichu);
		m_tuichu_ima.setNearAnchorUn(m_biaoqing_tit, Tools.RIGHT_VCENTER,
				Tools.RIGHT_VCENTER, 0, 0);
		m_tuichu_ima.setTouchZoomIn(40, 40);
		m_tuichu_ima.addListener(m_biaoqing_tuichu_lis);

		m_biaoqing_Frame.addControl(m_biaoqing_xbj_bg);
		m_biaoqing_Frame.addControl(m_biaoqing_tit);
		m_biaoqing_Frame.addControl(m_tit_ima_biaoqing);
		m_biaoqing_Frame.addControl(m_biaoqing_listbox);
		m_biaoqing_Frame.addControl(m_tuichu_ima);
		DWControlsManager.getInstance().addControl(m_biaoqing_Frame);
	}

	// //////退出监听
	private DWListener m_biaoqing_tuichu_lis = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			DWControlsManager.getInstance().removeControl(m_biaoqing_Frame);
			DWControlsManager.getInstance().addControl(m_liaotian_Frame);
		}
	};

	public void init()
	{
		// 加载图片
		m_cr_tuichu = UIWindows.createImage("/img/newui/fanhuianniu_1.gnp");// 叉键退出
		m_cr_tit = UIWindows.createImage("/img/newui/liaotian_1.gnp");
		m_cr_tit_biaoqing = UIWindows.createImage("/img/newui/tianjiabiaoqing_1.gnp");
		m_cr_tab_1 = UIWindows.createImage("/img/newui/biaoqianye_1.gnp");// 点击前图片
		m_cr_tab_2 = UIWindows.createImage("/img/newui/biaoqianye_2.gnp");// 点击后图片
		m_cr_but = UIWindows.createImage("/img/newui/anniu_6.gnp");// 发送
		m_cr_but_down = UIWindows.createImage("/img/newui/anniu_6ax.gnp");
		m_cr_xxbj = UIWindows.createImage("/img/newui/beibaobj_1.gnp");////小背景里面的2个小小背景呢
		m_cr_duanyu_tit = UIWindows.createImage("/img/newui/duanyu_1.gnp");///短语标题
		m_cr_caidan = UIWindows.createImage("/img/newui/jiantouanniu_6.gnp"); ///菜单
	}

	public void open(byte index)
	{
		// 开启方法
		if (!DWControlsManager.getInstance().contains(m_liaotian_Frame) && m_liaotian_Frame != null) {
			DWControlsManager.getInstance().addControl(m_liaotian_Frame);
			m_pindao_but.setName(m_pindao_name[m_tabcontrol.getPageIndex()]);
			m_inputbox.setText("");
		}
		else {
			LiaoTian();
		}
		if (m_chats_list != null) {
			for (int i = 0; i < m_chats_list.length; i++) {
				m_chats_list[i].setDown();
			}
		}
	}

	public void close(byte index)
	{
		// 关闭方法
	}

	public void dispose()
	{
		// 移除方法
	}

	private int m_jishi = 1;
	long m_start_time = 0;

	public void logic()
	{
		if (m_jishi > 0) {
			if (m_start_time == 0) {
				m_start_time = System.currentTimeMillis();///开始倒计时时截取系统时间
			}
			long m_currrent_time = System.currentTimeMillis();
			int time = (int) ((m_currrent_time - m_start_time) / 1000);
			if (m_jishi < time) {
				m_jishi = 1;
				updateChats();
				m_start_time = System.currentTimeMillis();
			}
		}
	}

	public long m_id_index = 0;
	public String m_name_index = "";

	public long ID(long m_id)
	{
		m_id_index = m_id;
		return m_id;
	}

	public String Name(String m_name)
	{
		m_name_index = m_name;
		return m_name_index;
	}
//	public boolean Flag(String m_sr)
//	{
//		for(int i=0;i<m_sr.toString().length();i++)
//		{
//			if(m_sr.indexOf(i)
//		}
//		m_flag_select = true;
//		return m_flag_select;
//	}
}
